package COM;
//计算器实现
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-03-24
 * Time: 16:33
 */
public class COM {

        public static void main(String[] args){
            double x;
            double y;
            char t;
            boolean f=true;
            Scanner in = new Scanner(System.in);
            while(f){
                System.out.println("请选择运算方式：+、-、*、/；或者退出：t");
                t=in.next().charAt(0);

                switch(t){
                    case '+':
                        System.out.println("请输入第一个数：");
                        x=in.nextDouble();
                        System.out.println("请输入第二个数：");
                        y=in.nextDouble();
                        System.out.println(x+"+"+y+"="+(x+y));
                        break;
                    case '-':
                        System.out.println("请输入减数：");
                        x=in.nextDouble();
                        System.out.println("请输入被减数：");
                        y=in.nextDouble();
                        System.out.println(x+"-"+y+"="+(x-y));
                        break;
                    case '*':
                        System.out.println("请输入要计算的第一个数：");
                        x=in.nextDouble();
                        System.out.println("请输入第二个要计算的数：");
                        y=in.nextDouble();
                        System.out.println(x+"*"+y+"="+(x*y));
                        break;
                    case '/':
                        System.out.println("输入除数：");
                        x=in.nextDouble();
                        System.out.println("输入被除数：");
                        y=in.nextDouble();
                        if(y==0)
                            System.out.println("错误");
                        else
                            System.out.println(x+"/"+y+"="+(x/y));
                        break;
                    case 't':
                        f=false;

                }
            }
        }
}
